use "M:\Userdata\Current\Projects\ENLaEX\Data\ENLaEX-final.dta", clear

*** Information regarding data set
describe
codebook
tab directive
tab derogation
tab extension
tab lower
tab amending

graph hbar (sum) requests, over(country, sort(1)) over(old) nofill blabel(total) ytitle("Sum of individual requests") title("Figure 1: Sum of individual requests by member state")
catplot type country, percent(country) stack asyvars over(old) nofill title("Figure 2: Use of different types of request (%) by country")
graph hbar (sum) requests if numcountries==1, over(country, sort(1)) over(old) nofill blabel(total) title("Figure 3: Sum of requests by single countries, by membership")  

*** Type of request (individual requests)
tab type
hist type, discrete percent addlabels addlabopts(yvarformat(%4.1f)) xlabel(1 "Derogation" 2 "Extension" 3 "Lower standard") ylabel(0 (20) 100) gap(10) title("Type of requests for individual requests") xtitle("Type of request") 
** by country
tabplot type country, percent(country) seperate(old) xlabel(, angle(90)) showval(mlabsize(tiny)) title("Figure 2: Use of different types of requests")

*** Success rate (individual requests)
tab cou_part_success if commonposition==1
tab cou_full_success  if commonposition==1
tab cou_part_success
tab cou_full_success
tab final_part_success
tab final_full_success

**** Analysis (country-level) *****

*** Creating country-level variables
* Number of requests (by country)
by country, sort: egen ms_total_requests=total(requests)
label variable ms_total_requests "Number of requests per country"
by country, sort: tab ms_total_requests

* Success rate of requests (by country)
by country, sort: tab success, missing
by country, sort: tab success
by country, sort: egen ms_success_pc_overall=mean(100*success) 
* Using the mean value per block (country and type), which is identical to the value itself, 
* to fill up missing values (which are needed later when only one observation per country is kept)
by country, sort: egen ms_success_pc_overall_miss=mean(ms_success_pc_overall)
by country, sort: replace ms_success_pc_overall=ms_success_pc_overall_miss if ms_success_pc_overall==.
label variable ms_success_pc_overall "Overall success rate (%)"
by country, sort: tab ms_success_pc_overall

by country, sort: tab final_full_success, missing
by country, sort: tab final_full_success
by country, sort: egen ms_success_pc_fin_ful=mean(100*final_full_success) 
label variable ms_success_pc_fin_ful "Complete success for adopted act (%)"
by country, sort: tab ms_success_pc_fin_ful

* Overall success rate of requests (by country and type)
* Sometimes very small N (by country and type)

tab type, missing
by country, sort: tab success if type==1
by country, sort: egen ms_success_pc_overall_derogation=mean(100*success) if type==1
by country, sort: egen ms_suc_pc_ov_der_miss=mean(ms_success_pc_overall_derogation)
by country, sort: replace ms_success_pc_overall_derogation=ms_suc_pc_ov_der_miss if ms_success_pc_overall_derogation==.
by country, sort: tab ms_success_pc_overall_derogation
by country, sort: tab success if type==2
by country, sort: egen ms_success_pc_overall_extension=mean(100*success) if type==2
by country, sort: egen ms_suc_pc_ov_ext_miss=mean(ms_success_pc_overall_extension)
by country, sort: replace ms_success_pc_overall_extension=ms_suc_pc_ov_ext_miss if ms_success_pc_overall_extension==.
by country, sort: tab ms_success_pc_overall_extension
by country, sort: tab success if type==3
by country, sort: egen ms_success_pc_overall_standards=mean(100*success) if type==3
by country, sort: egen ms_suc_pc_ov_std_miss=mean(ms_success_pc_overall_standards)
by country, sort: replace ms_success_pc_overall_standards=ms_suc_pc_ov_std_miss if ms_success_pc_overall_standards==.
by country, sort: tab ms_success_pc_overall_standards

linepatternst country success type if ms_success_pc_overall==.
linepatternst country success type if ms_success_pc_overall_derogation==.
linepatternst country success type if ms_success_pc_overall_extension==.
linepatternst country success type if ms_success_pc_overall_standards==.
* Result: No values for Luxembourg and derogations (missing value on success variable)

*** Collapsing data-set to country-level 
** Country-level variables are identical, just the first observation per country is kept
gen country_first=0
by country: replace country_first = 1 if _n == 1
by old, sort: sum ms_total_requests if country_first==1
drop requestID proposal COM COD title amending date_proposal date_polagree content document footnote article regulation directive commonposition recitals_initial recitals_cp recitals_final type requests success cou_part_success cou_full_success final_part_success final_full_success numcountries
drop if country_first==0
drop country_first

** Country-level data: graphs by country
sum ms_total_requests
graph hbar ms_total_requests, over(country, sort (1)) blabel (bar) ytitle("Number of requests per country")
graph bar ms_total_requests, over(country, sort (vweight)) blabel (bar) ytitle("Number of requests per country")
twoway scatter ms_total_requests vweight, xlabel(3 4 5 7 10 12 13 14 15 20 27 29 30) title("Number of requests per country and voting weights")
lowess ms_total_requests vweight
lowess ms_total_requests vweight, bwidth(0.6)
lowess ms_total_requests vweight, bwidth(0.4)
graph twoway scatter ms_total_requests vweight || lfit ms_total_requests vweight, xlabel(3 4 5 7 10 12 13 14 15 20 27 29 30) legend(label(2 "Regression linepatternne")) title("Number of requests per country and voting weights")

sum ms_success_pc_overall
graph hbar ms_success_pc_overall, over(country, sort (1)) blabel (bar, format(%9.1f)) ytitle("Success rate") title("Figure 4: Success rate (partial, 1st reading) per country (%)", span)

sum ms_success_pc_fin_ful
graph hbar ms_success_pc_fin_ful, over(country, sort (1)) blabel (bar, format(%9.1f)) ytitle("Success rate") title("Figure 5: Success rate (full, final) per country (%)", span)

linepatternst country ms_success_pc_overall_derogation
sum ms_success_pc_overall_derogation
graph hbar ms_success_pc_overall_derogation, over(country, sort (1)) blabel (bar, format(%9.1f)) title("Overall success rate per country for derogations (%)")

linepatternst country ms_success_pc_overall_extension
sum ms_success_pc_overall_extension
graph hbar ms_success_pc_overall_extension, over(country, sort (1)) blabel (bar, format(%9.1f)) title("Overall success rate per country for extensions (%)")

linepatternst country ms_success_pc_overall_standards
sum ms_success_pc_overall_standards
graph hbar ms_success_pc_overall_standards, over(country, sort (1)) blabel (bar, format(%9.1f)) title("Overall success rate per country for lower standards (%)")

** Graphs by country and membership
by old, sort: sum ms_total_requests
graph hbar ms_total_requests, over(country, sort (1)) over(old) nofill blabel (bar) ytitle("Number of requests per country")

by old, sort: sum ms_success_pc_overall
graph hbar ms_success_pc_overall, over(country, sort (1)) over(old) nofill blabel (bar, format(%9.1f)) ytitle("Success rate") title("Figure 4: Success rate (partial, 1st reading) per country (%)", span)

by old, sort: sum ms_success_pc_fin_ful
graph hbar ms_success_pc_fin_ful, over(country, sort (1)) over(old) nofill blabel (bar, format(%9.1f)) ytitle("Success rate") title("Figure 5: Success rate (full, final) per country (%)", span)

** Add observations for mean values (old and new member states)
* Total number of requests
by old, sort: sum ms_total_requests
set obs `=_N+1'
replace country="Average (old MS)" if _n==_N
replace old=1 if country=="Average (old MS)"
set obs `=_N+1'
replace country="Average (new MS)" if _n==_N
replace old=0 if country=="Average (new MS)"
gen ms_total_requestsavgold=.
sum ms_total_requests if old==1
replace ms_total_requestsavgold=r(mean) if country=="Average (old MS)"
gen ms_total_requestsall=ms_total_requestsavgold if country=="Average (old MS)"
sum ms_total_requests if old==0
replace ms_total_requestsavgold=r(mean) if country=="Average (new MS)"
replace ms_total_requestsall=ms_total_requestsavgold if country=="Average (new MS)"
format ms_total_requestsavgold %9.1f
* Combined graph
format %9.1f ms_total_requestsavgold
* not working for subsequent graphics command, changing directly
replace ms_total_requestsavgold = 26.3 in 29
graph bar ms_total_requests ms_total_requestsavgold, over(country, label(labsize(small) angle(90)) sort(ms_total_requestsall)) over(old) nofill blabel(bar, size(tiny)) legend(off) bar(1,  bstyle(p1bar)) bar(2,  bstyle(p5bar)) ytitle("Number of requests") b1title("Membership") title("a) by country", span) name(requestsbar) 
drop if country=="Average"
graph twoway scatter ms_total_requests vweight if old==1, mstyle(p1) || scatter ms_total_requests vweight if old==0, msymbol(sh) || lfit ms_total_requests vweight, xlabel(0(5)30) legend(label(1 "EU-15") labe(2 "New") label(3 "Regression linepatternne"))  title("b) by voting weight", span) name(requestscatter)
graph combine requestsbar requestscatter, title("Figure 1: Number of individual requests", justification(left) span) 

**** Unique requests ****

*** Collapsing data-set to unique request-level 
** Unique request-level variables are identical, just the first observation per unique request is kept
use "M:\Userdata\Current\Projects\ENLaEX\Data\ENLaEX-final.dta", clear
gen urequest_first=0
by requestID, sort: replace urequest_first = 1 if _n == 1
drop if urequest_first==0
drop urequest_first

* Descriptive Statistics (unique request)
tab success
tab cou_part_success if commonposition==1
tab cou_full_success  if commonposition==1
tab cou_part_success
tab cou_full_success
tab final_part_success
tab final_full_success

tab directive
tab derogation
tab extension
tab lower
tab amending

tab blocking

sum recitals_initial
sum numcountries
sum sumvotes

** Success rate by type
tab cou_part_success type if commonposition==1, column 
tab cou_part_success type, column
tab final_part_success type, column 

tab cou_full_success type if commonposition==1, column 
tab cou_full_success type, column
tab final_full_success type, column 


gen part_success=.
replace part_success=0 if (cou_part_success==0) & (final_part_success==0)
replace part_success=0 if (cou_part_success==0) & (final_part_success==.)
replace part_success=1 if (cou_part_success==1) | (final_part_success==1)
tab part_success type, column 

gen full_success=.
replace full_success=0 if (cou_full_success==0) & (final_full_success==0)
replace full_success=0 if (cou_full_success==0) & (final_full_success==.)
replace full_success=1 if (cou_full_success==1) | (final_full_success==1)
tab full_success type, column 


** Match Council success - final success
gen part_match=.
replace part_match=0 if cou_part_success!=final_part_success & commonposition==1 & cou_part_success!=. & final_part_success!=. 
replace part_match=1 if cou_part_success==final_part_success & commonposition==1 & cou_part_success!=. & final_part_success!=. 
tab part_match
linepatternst COM requestID cou_part_success final_part_success if cou_part_success!=final_part_success
linepatternst COM requestID if cou_part_success==1 & final_part_success==0
linepatternst COM requestID if cou_part_success==0 & final_part_success==1

gen full_match=.
replace full_match=0 if cou_full_success!=final_full_success & commonposition==1 & cou_full_success!=. & final_full_success!=. 
replace full_match=1 if cou_full_success==final_full_success & commonposition==1 & cou_full_success!=. & final_full_success!=. 
tab full_match
linepatternst COM requestID if cou_full_success==1 & final_full_success==0
linepatternst COM requestID if cou_full_success==0 & final_full_success==1


** Success rate by type (graph)
graph bar (mean)cou_part_success (mean)final_part_success (mean)cou_full_success (mean)final_full_success
graph bar (mean)cou_part_success (mean)cou_full_success (mean)final_part_success (mean)final_full_success
ktau cou_part_success final_part_success
ktau cou_full_success final_full_success

* creating average values scaled to percentage level for graph
egen cp_part_success_pct=mean(cou_part_success) if commonposition==1 & cou_part_success!=.
replace cp_part_success_pct=cp_part_success_pct*100
egen cou_part_success_pct=mean(cou_part_success)
replace cou_part_success_pct=cou_part_success_pct*100
egen cp_full_success_pct=mean(cou_full_success)  if commonposition==1 & cou_part_success!=.
replace cp_full_success_pct=cp_full_success_pct*100
egen cou_full_success_pct=mean(cou_full_success)
replace cou_full_success_pct=cou_full_success_pct*100
egen final_part_success_pct=mean(final_part_success)
replace final_part_success_pct=final_part_success_pct*100
egen final_full_success_pct=mean(final_full_success)
replace final_full_success_pct=final_full_success_pct*100
* Using max value to single out one (arbitrary, all values are identical) value
graph bar (max)cou_part_success_pct (max)final_part_success_pct (max)cou_full_success_pct (max)final_full_success_pct, legend(label (1 "Partial, 1st reading") label (2 "Partial, final") label (3 "Full, 1st reading") label(4 "Full, final")) bargap(10) blabel(bar, format(%5.1f)) ytitle("Success rate (%)") ylabel(0(10)100) 
graph bar (max)cp_part_success_pct (max)cou_part_success_pct (max)final_part_success_pct (max)cp_full_success_pct (max)cou_full_success_pct (max)final_full_success_pct, legend(rows(2) label(1 "Partial, Common Position") label(2 "Partial, 1st reading") label (3 "Partial, final") label(4 "Full, Common Position") label(5 "Full, 1st reading") label(6 "Full, final") size(vsmall) symxsize(*.3) symysize(*.9) span) bargap(10) blabel(bar, format(%5.1f)) ytitle("Success rate (%)", size(small)) ylabel(0(20)100) title("a) by degree and stage") name(success_a)

** Success rate by type of legislation
tab amending directive, column
label var directive "Type of legislation"
label define dir_label 0  "Regulation" 1 "Directive"
label values directive dir_label
graph bar (mean)success, over(amending) 
tab success amending, column
graph bar (mean)success, over(directive)
tab success directive, column
egen cou_part_success_avgdir=mean(cou_part_success), by(directive)
replace cou_part_success_avgdir=cou_part_success_avgdir*100
egen final_full_success_avgdir=mean(final_full_success), by(directive)
replace final_full_success_avgdir=final_full_success_avgdir*100
graph bar (max)cou_part_success_avgdir (max)final_full_success_avgdir, over(directive) blabel(bar, format(%5.1f)) title("Figure 3: Success rate by type of legislation", span) ytitle("Success rate (%)") ylabel(0(10)100) b1title("Type of legislation")  legend(label (1 "Partial, Council") label(2 "Full, final")) 

** Success rate overall by type of request
graph bar (mean)cou_part_success (mean)cou_full_success (mean)final_part_success (mean)final_full_success, over(type) blabel(bar) title ("Figure 2: Success rates for unique requests", span) ylabel(.1 "10" .2 "20" .3  "30" .4 "40" .5 "50" .6 "60" .7 "70".8 "80" .9 "90") ytitle("Success rate (%)") b1title("Type of request") 

graph bar (mean)cou_part_success (mean)final_full_success, over(type) blabel(bar) title("Figure 2: Success rates for unique requests", span) ylabel(.1 "10" .2 "20" .3  "30" .4 "40" .5 "50" .6 "60" .7 "70".8 "80" .9 "90") ytitle("Success rate (%)") b1title("Type of request") 
* Creating mean value as success percentage for plot
egen cou_part_success_avgtype=mean(cou_part_success), by(type)
replace cou_part_success_avgtype=cou_part_success_avgtype*100
egen final_full_success_avgtype=mean(final_full_success), by(type)
replace final_full_success_avgtype=final_full_success_avgtype*100
graph bar (max)cou_part_success_avgtype (max)final_full_success_avgtype, over(type) blabel(bar, format(%5.1f)) title("Figure 2: Success rate for unique requests", span) ytitle("Success rate (%)") ylabel(0(10)100) b1title("Type of request")  legend(label (1 "Partial, Council") label(2 "Full, final")) 
graph bar (max)cou_part_success_avgtype (max)final_full_success_avgtype, over(type) blabel(bar, format(%5.1f)) title("b) by type of request", span) ytitle("Success rate (%)", size(small)) ylabel(0(20)100) legend(label (1 "Partial, 1st reading") label(2 "Full, final") size(small))  name(success_b)

** Success rate overall by number of countries
by numcountries, sort: tab success
graph bar (mean)success, over(numcountries)
graph bar (mean)cou_part_success (mean)final_full_success, over(numcountries) legend(label (1 "Partial, Council") label(2 "Full, final")) 
egen cou_part_success_avgnum=mean(cou_part_success), by(numcountries)
replace cou_part_success_avgnum=cou_part_success_avgnum*100
egen final_full_success_avgnum=mean(final_full_success), by(numcountries)
replace final_full_success_avgnum=final_full_success_avgnum*100
graph bar (max)cou_part_success_avgnum (max)final_full_success_avgnum, over(numcountries) blabel(bar, format(%5.0f) size(tiny)) bargap(5) title("Figure 2: Success rate by number of countries", span) ytitle("Success rate (%)") ylabel(0(10)100) b1title("Number of countries")  legend(label (1 "Partial, 1st reading") label(2 "Full, final")) 
graph bar (max)cou_part_success_avgnum (max)final_full_success_avgnum, over(numcountries) blabel(bar, format(%5.0f) size(tiny)) bargap(5) title("c) by number of countries", span) ytitle("Success rate (%)", size(small)) ylabel(0(20)100) legend(label (1 "Partial, 1st reading") label(2 "Full, final") size(small)) name(success_c)

** Sumvotes (categorical, theoretically interesting categories)
tab cou_part_success blocking, column
tab final_full_success blocking, column

* Blocking minority requires 90 (EU-25) or 91 (EU-27) votes
tab sumvotes
* Only one request which has exactly 90 votes (no for exactly 91)
linepatternst COM requestID date_polagree if sumvotes==90
* The only request with exactly 90 votes was agree upon within EU-27, hence 91 votes will be used as threshold (blocking minority: sumvotes>=91)
* Three requests are 12 votes away (68)
linepatternst COM requestID date_polagree if sumvotes==68
* Those with dates (2) are during EU-25, hence 68 is cut-off (for being close to/ one vote away from blocking minority of 90)
gen sumvotescat=. 
label variable sumvotescat "Sum of voting weights of requesting countries"
label define sumvotescat_label 1 "<37" 2 "37-66" 3 "67-78" 4 "79-90" 5 "91-102" 6 "103-114" 7 "115-137" 8 ">137"
label values sumvotescat sumvotescat_label
* Category 1: just a few countries (constitutes about 50% of the data)
replace sumvotescat=1 if sumvotes<37
* Category 2: very far away from blocking minority (more than 24 votes away; 12 is modus for voting weights) 
replace sumvotescat=2 if sumvotes>=37 & sumvotes<=66
* Category 3: far away from blocking minority (more than 12 votes away)
replace sumvotescat=3 if sumvotes>=67 & sumvotes<=78
* Category 4: close to blocking minority (within one vote (12 votes) of blocking minority)
replace sumvotescat=4 if sumvotes>=79 & sumvotes<=90
* Category 5: blocking minority (but one defection (12 votes) could turn it into losing coalinepatterntion)
replace sumvotescat=5 if sumvotes>=91 & sumvotes<=102
* Category 6: blocking minority (but two defections (24 votes) could turn it into losing coalinepatterntion)
replace sumvotescat=6 if sumvotes>=103 & sumvotes<=114
* Category 7: blocking minority (safe from two defections (24 votes))
replace sumvotescat=7 if sumvotes>=115 & sumvotes<=137
* Category 8: Very large coalinepatterntion (highest 10%) 
replace sumvotescat=8 if sumvotes>137

tab sumvotescat, missing
tab success sumvotescat, column
graph bar (mean)success, over(sumvotescat) blabel(bar)

egen cou_part_success_sv=mean(cou_part_success), by(sumvotescat)
replace cou_part_success_sv=cou_part_success_sv*100
egen final_full_success_sv=mean(final_full_success), by(sumvotescat)
replace final_full_success_sv=final_full_success_sv*100
graph bar (max)cou_part_success_sv (max)final_full_success_sv, over(sumvotescat) blabel(bar, format(%5.1f) size(small)) bargap(5) title("Figure 3: Success rate by sum of votes", span) ytitle("Success rate (%)") ylabel(0(10)100) b1title("Sum of votes")  legend(label (1 "Partial, 1st reading") label(2 "Full, final")) 
graph bar (max)cou_part_success_sv (max)final_full_success_sv, over(sumvotescat, label(angle(45) labsize(small))) blabel(bar, format(%5.1f) size(vsmall)) bargap(5) title("d) by sum of votes", span) ytitle("Success rate (%)", size(small)) ylabel(0(20)100) legend(label (1 "Partial, 1st reading") label(2 "Full, final") size(small)) name(success_d)
graph combine success_a success_b success_c success_d, title("Figure 3: Success rates of unique requests") ycommon  

*** Testing differences in proportions for success (blocking minority) 

tab blocking success, row chi
prtest success, by(blocking)
graph bar success, over(blocking) ytitle("Success rate") b1title("Blocking minority") title("Overall Success Rate and Blocking Minority")

tab blocking cou_part_success if commonposition==1, row chi
prtest success, by(blocking) chi
graph bar cou_part_success if commonposition==1, over(blocking) ytitle("Success rate") b1title("Blocking minority") title("a) partial, Common Position") name(h1_a)

tab blocking cou_full_success if commonposition==1, row chi
prtest success, by(blocking)
graph bar cou_full_success if commonposition==1, over(blocking) ytitle("Success rate") b1title("Blocking minority") title("b) full, Common Position")  name(h1_b)

tab blocking cou_part_success, row chi
prtest success, by(blocking)
graph bar cou_part_success, over(blocking) ytitle("Success rate") b1title("Blocking minority") title("c) partial, first reading")   name(h1_c)

tab blocking cou_full_success, row chi
prtest success, by(blocking)
graph bar cou_full_success, over(blocking) ytitle("Success rate") b1title("Blocking minority") title("d) full, first reading")  name(h1_d)

tab blocking final_part_success, row chi
prtest success, by(blocking)
graph bar final_part_success, over(blocking) ytitle("Success rate") b1title("Blocking minority") title("e) partial, final")  name(h1_e)

tab blocking final_full_success, row chi
prtest success, by(blocking)
graph bar final_full_success, over(blocking) ytitle("Success rate") b1title("Blocking minority") title("f) full, final")  name(h1_f)

graph combine h1_a h1_b h1_c h1_d h1_e h1_f, ycommon title("Figure 2: Blocking Minorities and Success Rates")
graph combine h1_a h1_b h1_c h1_d h1_e h1_f, ycommon 
graph drop h1_a h1_b h1_c h1_d h1_e h1_f


*** Logistic regression ****

use "M:\Userdata\Current\Projects\ENLaEX\Data\ENLaEX-final.dta", clear
*** collapse to unique request level
gen urequest_first=0
by requestID, sort: replace urequest_first = 1 if _n == 1
drop if urequest_first==0
drop urequest_first

*** Regression analysis - single level

** Functional form

* Functional form: sum of votes
lowess cou_part_success sumvotes, jitter(2) bwidth(.8) xlinepatternne(91) name(cps_lowess8)
lowess cou_part_success sumvotes, jitter(2) bwidth(.2) xlinepatternne(91) name(cps_lowess2)
lowess cou_part_success sumvotes, jitter(2) bwidth(.6) xlinepatternne(91) name(cps_lowess4)
lowess cou_part_success sumvotes, jitter(2) bwidth(.6) xlinepatternne(91) name(cps_lowess6)
graph combine cps_lowess8 cps_lowess6 cps_lowess4 cps_lowess2, title("Figure 1: Scatterplot smoother")
gen sumvotes_log=log(sumvotes)
lowess cou_part_success sumvotes_log, jitter(2) bwidth(.8) name(cps_lowess8_log)
lowess cou_part_success sumvotes_log, jitter(2) bwidth(.2) name(cps_lowess2_log)
lowess cou_part_success sumvotes_log, jitter(2) bwidth(.6) name(cps_lowess4_log)
lowess cou_part_success sumvotes_log, jitter(2) bwidth(.6) name(cps_lowess6_log)
graph combine cps_lowess8_log cps_lowess6_log cps_lowess4_log cps_lowess2_log, title("Figure 2: Scatterplot smoother (logged values)")
gen sumvotes_sqrt=sqrt(sumvotes)
lowess cou_part_success sumvotes_sqrt, jitter(2) bwidth(.8) name(cps_lowess8_sqrt)
lowess cou_part_success sumvotes_sqrt, jitter(2) bwidth(.2) name(cps_lowess2_sqrt)
lowess cou_part_success sumvotes_sqrt, jitter(2) bwidth(.6) name(cps_lowess4_sqrt)
lowess cou_part_success sumvotes_sqrt, jitter(2) bwidth(.6) name(cps_lowess6_sqrt)
graph combine cps_lowess8_sqrt cps_lowess6_sqrt cps_lowess4_sqrt cps_lowess2_sqrt, title("Figure 3: Scatterplot smoother (square root of values)")
lowess cou_part_success sumvotes if commonposition==1, jitter(2) bwidth(.8) xlinepatternne(91) name(cou_lowess8)
lowess cou_part_success sumvotes if commonposition==1, jitter(2) bwidth(.2) xlinepatternne(91) name(cou_lowess2)
lowess cou_part_success sumvotes if commonposition==1, jitter(2) bwidth(.6) xlinepatternne(91) name(cou_lowess4)
lowess cou_part_success sumvotes if commonposition==1, jitter(2) bwidth(.6) xlinepatternne(91) name(cou_lowess6)
graph combine cps_lowess8 cps_lowess6 cps_lowess4 cps_lowess2, title("Figure 4: Scatterplot smoother (partial, Council)")
lowess final_full_success sumvotes, jitter(2) bwidth(.8) xlinepatternne(91) name(ff_lowess8)
lowess final_full_success sumvotes, jitter(2) bwidth(.2) xlinepatternne(91) name(ff_lowess2)
lowess final_full_success sumvotes, jitter(2) bwidth(.6) xlinepatternne(91) name(ff_lowess4)
lowess final_full_success sumvotes, jitter(2) bwidth(.6) xlinepatternne(91) name(ff_lowess6)
graph combine ff_lowess8 ff_lowess6 ff_lowess4 ff_lowess2, title("Figure 5: Scatterplot smoother (full, final)")

* Functional form: sum of votes, different models
logistic cou_part_success sumvotes i.type amending directive recitals_initial if commonposition==1, coef 
estimates store cp_part_cl_svnorm
logistic cou_part_success sumvotes_log i.type amending directive recitals_initial if commonposition==1, coef 
estimates store cp_part_cl_svlogged
logistic cou_full_success sumvotes i.type amending directive recitals_initial if commonposition==1, coef 
estimates store cp_full_cl_svnorm
logistic cou_full_success sumvotes_log i.type amending directive recitals_initial if commonposition==1, coef 
estimates store cp_full_cl_svlogged
logistic cou_part_success sumvotes i.type amending directive recitals_initial, coef
estimates store first_part_cl_svnorm
logistic cou_part_success sumvotes_log i.type amending directive recitals_initial, coef
estimates store first_part_cl_svlogged
logistic cou_full_success sumvotes i.type amending directive recitals_initial, coef
estimates store first_full_cl_svnorm
logistic cou_full_success sumvotes_log i.type amending directive recitals_initial, coef
estimates store first_full_cl_svlogged
logistic final_part_success sumvotes i.type amending directive recitals_initial, coef
estimates store final_part_cl_svnorm
logistic final_part_success sumvotes_log i.type amending directive recitals_initial, coef
estimates store final_part_cl_svlogged
logistic final_full_success sumvotes i.type amending directive recitals_initial, coef
estimates store final_full_cl_svnorm
logistic final_full_success sumvotes_log i.type amending directive recitals_initial, coef
estimates store final_full_cl_svlogged
estout cp_part_cl_svnorm cp_part_cl_svlogged cp_full_cl_svnorm cp_full_cl_svlogged first_part_cl_svnorm first_part_cl_svlogged, stats(N r2_p p) drop(1.type) starlevels( * 0.10 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) legend mlabels(none)
estout first_full_cl_svnorm first_full_cl_svlogged final_part_cl_svnorm final_part_cl_svlogged final_full_cl_svnorm final_full_cl_svlogged, stats(N r2_p p) drop(1.type) starlevels( * 0.10 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) legend mlabels(none)


* Functional form: recitals
lowess cou_part_success recitals_initial, jitter(2) bwidth(.8) xlinepatternne(91) name(cps_rec_lowess8)
lowess cou_part_success recitals_initial, jitter(2) bwidth(.2) xlinepatternne(91) name(cps_rec_lowess2)
lowess cou_part_success recitals_initial, jitter(2) bwidth(.6) xlinepatternne(91) name(cps_rec_lowess4)
lowess cou_part_success recitals_initial, jitter(2) bwidth(.6) xlinepatternne(91) name(cps_rec_lowess6)
graph combine cps_rec_lowess8 cps_rec_lowess6 cps_rec_lowess4 cps_rec_lowess2, title("Figure 6: Scatterplot smoother for recitals")

* Functional form: recitals, different models
gen recitals_logged=log(recitals_initial)
logistic cou_part_success sumvotes i.type amending directive recitals_initial if commonposition==1, coef 
estimates store cp_part_cl_norm
logistic cou_part_success sumvotes i.type amending directive recitals_logged if commonposition==1, coef 
estimates store cp_part_cl_logged
logistic cou_full_success sumvotes i.type amending directive recitals_initial if commonposition==1, coef 
estimates store cp_full_cl_norm
logistic cou_full_success sumvotes i.type amending directive recitals_logged if commonposition==1, coef 
estimates store cp_full_cl_logged
logistic cou_part_success sumvotes i.type amending directive recitals_initial, coef
estimates store first_part_cl_norm
logistic cou_part_success sumvotes i.type amending directive recitals_logged, coef
estimates store first_part_cl_logged
logistic cou_full_success sumvotes i.type amending directive recitals_initial, coef
estimates store first_full_cl_norm
logistic cou_full_success sumvotes i.type amending directive recitals_logged, coef
estimates store first_full_cl_logged
logistic final_part_success sumvotes i.type amending directive recitals_initial, coef
estimates store final_part_cl_norm
logistic final_part_success sumvotes i.type amending directive recitals_logged, coef
estimates store final_part_cl_logged
logistic final_full_success sumvotes i.type amending directive recitals_initial, coef
estimates store final_full_cl_norm
logistic final_full_success sumvotes i.type amending directive recitals_logged, coef
estimates store final_full_cl_logged

estout cp_part_cl_norm cp_part_cl_logged cp_full_cl_norm cp_full_cl_logged first_part_cl_norm first_part_cl_logged, stats(N r2_p p) drop(1.type) starlevels( * 0.10 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) legend mlabels(none)
estout first_full_cl_norm first_full_cl_logged final_part_cl_norm final_part_cl_logged final_full_cl_norm final_full_cl_logged, stats(N r2_p p) drop(1.type) starlevels( * 0.10 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) legend mlabels(none)

** Comparison of different model specification: control variables

* Partial, Common Position (Table 1)
logistic cou_part_success sumvotes if commonposition==1, coef
estimates store cp_part_nmodel
logistic cou_part_success sumvotes i.type  if commonposition==1, coef 
estimates store cp_part_typemodel
lrtest cp_part_typemodel cp_part_nmodel
logistic cou_part_success sumvotes amending directive if commonposition==1, coef
estimates store cp_part_propmodel
lrtest cp_part_propmodel cp_part_nmodel
logistic cou_part_success sumvotes recitals_initial if commonposition==1, coef
estimates store cp_part_recmodel
lrtest cp_part_recmodel cp_part_nmodel
logistic cou_part_success sumvotes i.type amending directive  if commonposition==1, coef
estimates store cp_part_typepropmodel
lrtest cp_part_typepropmodel cp_part_nmodel
logistic cou_part_success sumvotes i.type recitals_initial  if commonposition==1, coef
estimates store cp_part_typerecmodel
lrtest cp_part_typerecmodel cp_part_nmodel
logistic cou_part_success sumvotes i.type amending directive recitals_initial  if commonposition==1, coef
estimates store cp_part_fmodel
lrtest cp_part_fmodel cp_part_nmodel

estout cp_part_nmodel cp_part_typemodel cp_part_propmodel cp_part_recmodel cp_part_typepropmodel cp_part_typerecmodel cp_part_fmodel, stats(N r2_p p) drop(1.type) starlevels( * 0.10 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) legend mlabels(, numbers)


* Partial, first reading (Table 2)
logistic cou_part_success sumvotes, coef
estimates store first_part_nmodel
logistic cou_part_success sumvotes i.type, coef 
estimates store first_part_typemodel
lrtest first_part_typemodel first_part_nmodel
logistic cou_part_success sumvotes amending directive, coef
estimates store first_part_propmodel
lrtest first_part_propmodel first_part_nmodel
logistic cou_part_success sumvotes recitals_initial, coef
estimates store first_part_recmodel
lrtest first_part_recmodel first_part_nmodel
logistic cou_part_success sumvotes i.type amending directive, coef
estimates store first_part_typepropmodel
lrtest first_part_typepropmodel first_part_nmodel
logistic cou_part_success sumvotes i.type recitals_initial, coef
estimates store first_part_typerecmodel
lrtest first_part_typerecmodel first_part_nmodel
logistic cou_part_success sumvotes i.type amending directive recitals_initial, coef
estimates store first_part_fmodel
lrtest first_part_fmodel first_part_nmodel

estout first_part_nmodel first_part_typemodel first_part_propmodel first_part_recmodel first_part_typepropmodel first_part_typerecmodel first_part_fmodel, stats(N r2_p p) drop(1.type) starlevels( * 0.10 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) legend mlabels(none)

* Partial, final (Table 3)
logistic final_part_success sumvotes, coef
estimates store final_part_nmodel
logistic final_part_success sumvotes i.type, coef 
estimates store final_part_typemodel
lrtest final_part_typemodel final_part_nmodel
logistic final_part_success sumvotes amending directive, coef
estimates store final_part_propmodel
lrtest final_part_propmodel final_part_nmodel
logistic final_part_success sumvotes recitals_initial, coef
estimates store final_part_recmodel
lrtest final_part_recmodel final_part_nmodel
logistic final_part_success sumvotes i.type amending directive, coef
estimates store final_part_typepropmodel
lrtest final_part_typepropmodel final_part_nmodel
logistic final_part_success sumvotes i.type recitals_initial, coef
estimates store final_part_typerecmodel
lrtest final_part_typerecmodel final_part_nmodel
logistic final_part_success sumvotes i.type amending directive recitals_initial, coef
estimates store final_part_fmodel
lrtest final_part_fmodel final_part_nmodel

estout final_part_nmodel final_part_typemodel final_part_propmodel final_part_recmodel final_part_typepropmodel final_part_typerecmodel final_part_fmodel, stats(N r2_p p) drop(1.type) starlevels( * 0.10 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) legend mlabels(none)

* Full, Common Position (Table 4)
logistic cou_full_success sumvotes if commonposition==1, coef
estimates store cp_full_nmodel
logistic cou_full_success sumvotes i.type  if commonposition==1, coef 
estimates store cp_full_typemodel
lrtest cp_full_typemodel cp_full_nmodel
logistic cou_full_success sumvotes amending directive if commonposition==1, coef
estimates store cp_full_propmodel
lrtest cp_full_propmodel cp_full_nmodel
logistic cou_full_success sumvotes recitals_initial if commonposition==1, coef
estimates store cp_full_recmodel
lrtest cp_full_recmodel cp_full_nmodel
logistic cou_full_success sumvotes i.type amending directive  if commonposition==1, coef
estimates store cp_full_typepropmodel
lrtest cp_full_typepropmodel cp_full_nmodel
logistic cou_full_success sumvotes i.type recitals_initial  if commonposition==1, coef
estimates store cp_full_typerecmodel
lrtest cp_full_typerecmodel cp_full_nmodel
logistic cou_full_success sumvotes i.type amending directive recitals_initial  if commonposition==1, coef
estimates store cp_full_fmodel
lrtest cp_full_fmodel cp_full_nmodel

estout cp_full_nmodel cp_full_typemodel cp_full_propmodel cp_full_recmodel cp_full_typepropmodel cp_full_typerecmodel cp_full_fmodel, stats(N r2_p p) drop(1.type) starlevels( * 0.10 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) legend mlabels(, numbers)

* Full, first reading (Table 5)
logistic cou_full_success sumvotes, coef
estimates store first_full_nmodel
logistic cou_full_success sumvotes i.type, coef 
estimates store first_full_typemodel
lrtest first_full_typemodel first_full_nmodel
logistic cou_full_success sumvotes amending directive, coef
estimates store first_full_propmodel
lrtest first_full_propmodel first_full_nmodel
logistic cou_full_success sumvotes recitals_initial, coef
estimates store first_full_recmodel
lrtest first_full_recmodel first_full_nmodel
logistic cou_full_success sumvotes i.type amending directive, coef
estimates store first_full_typepropmodel
lrtest first_full_typepropmodel first_full_nmodel
logistic cou_full_success sumvotes i.type recitals_initial, coef
estimates store first_full_typerecmodel
lrtest first_full_typerecmodel first_full_nmodel
logistic cou_full_success sumvotes i.type amending directive recitals_initial, coef
estimates store first_full_fmodel
lrtest first_full_fmodel first_full_nmodel

estout first_full_nmodel first_full_typemodel first_full_propmodel first_full_recmodel first_full_typepropmodel first_full_typerecmodel first_full_fmodel, stats(N r2_p p) drop(1.type) starlevels( * 0.10 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) legend mlabels(none)

* Full, final (Table 6)
logistic final_full_success sumvotes, coef
estimates store final_full_nmodel
logistic final_full_success sumvotes i.type, coef 
estimates store final_full_typemodel
lrtest final_full_typemodel final_full_nmodel
logistic final_full_success sumvotes amending directive, coef
estimates store final_full_propmodel
lrtest final_full_propmodel final_full_nmodel
logistic final_full_success sumvotes recitals_initial, coef
estimates store final_full_recmodel
lrtest final_full_recmodel final_full_nmodel
logistic final_full_success sumvotes i.type amending directive, coef
estimates store final_full_typepropmodel
lrtest final_full_typepropmodel final_full_nmodel
logistic final_full_success sumvotes i.type recitals_initial, coef
estimates store final_full_typerecmodel
lrtest final_full_typerecmodel final_full_nmodel
logistic final_full_success sumvotes i.type amending directive recitals_initial, coef
estimates store final_full_fmodel
lrtest final_full_fmodel final_full_nmodel

estout final_full_nmodel final_full_typemodel final_full_propmodel final_full_recmodel final_full_typepropmodel final_full_typerecmodel final_full_fmodel, stats(N r2_p p) drop(1.type) starlevels( * 0.10 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) legend mlabels(none)

** Full model: Blocking minority
logistic cou_part_success blocking i.type amending directive recitals_initial  if commonposition==1, coef
logistic cou_part_success blocking i.type amending directive recitals_initial, coef
logistic final_part_success blocking i.type amending directive recitals_initial, coef
logistic cou_full_success blocking i.type amending directive recitals_initial  if commonposition==1, coef
logistic cou_full_success blocking i.type amending directive recitals_initial, coef
logistic final_full_success blocking i.type amending directive recitals_initial, coef

** General fit: full model
logistic cou_part_success sumvotes i.type amending directive recitals_initial  if commonposition==1, coef
lroc, name(lroc_cp_part) title("a) Partial success, CP")
estat class
logistic cou_part_success sumvotes i.type amending directive recitals_initial, coef
lroc, name(lroc_first_part) title("b) Partial success, 1st rdg.")
estat class
logistic final_part_success sumvotes i.type amending directive recitals_initial, coef
lroc, name(lroc_final_part) title("c) Partial success, final act")
estat class
logistic cou_full_success sumvotes i.type amending directive recitals_initial  if commonposition==1, coef
lroc, name(lroc_cp_full) title("d) Full success, CP")
estat class
logistic cou_full_success sumvotes i.type amending directive recitals_initial, coef
lroc, name(lroc_first_full) title("e) Full success, 1st rdg.")
estat class
logistic final_full_success sumvotes i.type amending directive recitals_initial, coef
lroc, name(lroc_final_full) title("f) Full success, final act")
graph combine lroc_cp_part lroc_first_part lroc_final_part lroc_cp_full lroc_first_full lroc_final_full, title("Figure 7: ROC curve") 


** Residuals
* CP, part
logistic cou_part_success sumvotes extension derogation amending directive recitals_initial if commonposition==0, coef
predict phat
predict rstd, rs
label var rstd "Standardized residual"
graph twoway scatter rstd requestID, ylabel(-4(2)4) msymbol(none) mlabel(requestID) name(rstd_id)
graph twoway scatter rstd phat, ylabel(-4(2)4) xlabel(0(1)1) msymbol(none) mlabel(requestID) name(rstd_phat) b1title("Probabilinepatternty of success")
graph twoway scatter rstd date_polagree, ylabel(-4(2)4) msymbol(none) mlabel(requestID) name(rstd_date) 
graph combine rstd_id rstd_phat rstd_date, title("Figure 8: Standardized residuals (partial, CP)")
* Three observations stand out (130, 187, 193)
logistic cou_full_success sumvotes extension derogation amending directive recitals_initial if commonposition==0, coef
predict phat_cp_full
predict rstd_cp_full, rs
label var rstd_cp_full "Standardized residual"
graph twoway scatter rstd_cp_full requestID, ylabel(-4(2)4) msymbol(none) mlabel(requestID) name(rstd_id_cp_full)
graph twoway scatter rstd_cp_full phat_cp_full, ylabel(-4(2)4) xlabel(0(1)1) msymbol(none) mlabel(requestID) name(rstd_phat_cp_full) b1title("Probabilinepatternty of success")
graph twoway scatter rstd_cp_full date_polagree, ylabel(-4(2)4) msymbol(none) mlabel(requestID) name(rstd_date_cp_full) 
graph combine rstd_id_cp_full rstd_phat_cp_full rstd_date_cp_full, title("Figure 9: Standardized residuals (full, CP)")
* Two observations stand out (192, 193)
logistic cou_part_success sumvotes extension derogation amending directive recitals_initial, coef
predict phat_first_part
predict rstd_first_part, rs
label var rstd_first_part "Standardized residual"
graph twoway scatter rstd_first_part requestID, ylabel(-4(2)4) msymbol(none) mlabel(requestID) name(rstd_id_first_part)
graph twoway scatter rstd_first_part phat_first_part, ylabel(-4(2)4) xlabel(0(1)1) msymbol(none) mlabel(requestID) name(rstd_phat_first_part) b1title("Probabilinepatternty of success")
graph twoway scatter rstd_first_part date_polagree, ylabel(-4(2)4) msymbol(none) mlabel(requestID) name(rstd_date_first_part) 
graph twoway scatter rstd_first_part commonposition, ylabel(-4(2)4) xlabel(0(1)1) msymbol(none) mlabel(requestID) name(rstd_cp_first_part)
graph combine rstd_id_first_part rstd_phat_first_part rstd_date_first_part rstd_cp_first_part, title("Figure 10: Standardized residuals (partial, 1st rdg.)")
* Four observations stand out (58, 124, 130, 193) 
logistic cou_full_success sumvotes extension derogation amending directive recitals_initial, coef
predict phat_first_full
predict rstd_first_full, rs
label var rstd_first_full "Standardized residual"
graph twoway scatter rstd_first_full requestID, ylabel(-4(2)4) msymbol(none) mlabel(requestID) name(rstd_id_first_full)
graph twoway scatter rstd_first_full phat_first_full, ylabel(-4(2)4) xlabel(0(1)1) msymbol(none) mlabel(requestID) name(rstd_phat_first_full) b1title("Probabilinepatternty of success")
graph twoway scatter rstd_first_full date_polagree, ylabel(-4(2)4) msymbol(none) mlabel(requestID) name(rstd_date_first_full) 
graph twoway scatter rstd_first_part commonposition, ylabel(-4(2)4) xlabel(0(1)1) msymbol(none) mlabel(requestID) name(rstd_cp_first_full)
graph combine rstd_id_first_full rstd_phat_first_full rstd_date_first_full rstd_cp_first_full, title("Figure 11: Standardized residuals (full, 1st rdg.)")
* Four observations stand out (58, 124, 130, 193) 
logistic final_part_success sumvotes extension derogation amending directive recitals_initial, coef
predict phat_final_part
predict rstd_final_part, rs
label var rstd_final_part "Standardized residual"
graph twoway scatter rstd_final_part requestID, ylabel(-4(2)4) msymbol(none) mlabel(requestID) name(rstd_id_final_part)
graph twoway scatter rstd_final_part phat_final_part, ylabel(-4(2)4) xlabel(0(1)1) msymbol(none) mlabel(requestID) name(rstd_phat_final_part) b1title("Probabilinepatternty of success")
graph twoway scatter rstd_final_part date_polagree, ylabel(-4(2)4) msymbol(none) mlabel(requestID) name(rstd_date_final_part) 
graph twoway scatter rstd_final_part commonposition, ylabel(-4(2)4) xlabel(0(1)1) msymbol(none) mlabel(requestID) name(rstd_cp_final_part)
graph combine rstd_id_final_part rstd_phat_final_part rstd_date_final_part rstd_cp_final_part, title("Figure 12: Standardized residuals (partial, final)")
* Seven observations stand out (58, 124, 130, 142, 193, 194, 195)
logistic final_full_success sumvotes extension derogation amending directive recitals_initial, coef
predict phat_final_full
predict rstd_final_full, rs
label var rstd_final_full "Standardized residual"
graph twoway scatter rstd_final_full requestID, ylabel(-4(2)4) msymbol(none) mlabel(requestID) name(rstd_id_final_full)
graph twoway scatter rstd_final_full phat_final_full, ylabel(-4(2)4) xlabel(0(1)1) msymbol(none) mlabel(requestID) name(rstd_phat_final_full) b1title("Probabilinepatternty of success")
graph twoway scatter rstd_final_full date_polagree, ylabel(-4(2)4) msymbol(none) mlabel(requestID) name(rstd_date_final_full) 
graph twoway scatter rstd_final_full commonposition, ylabel(-4(2)4) xlabel(0(1)1) msymbol(none) mlabel(requestID) name(rstd_cp_final_full)
graph combine rstd_id_final_full rstd_phat_final_full rstd_date_final_full rstd_cp_final_full, title("Figure 13: Standardized residuals (full, final)")
linepatternst requestID if abs(rstd_final_full)>=2 & rstd_final_full!=.
* Nine observations stand out (8, 22, 57, 64, 85, 127, 139, 172, 173)

** Influential cases
logistic cou_part_success sumvotes i.type amending directive recitals_initial if commonposition==1, coef
estimates store cp_part
predict leverage_cp_part, dbeta
label var leverage_cp_part "Leverage"
graph twoway scatter leverage_cp_part requestID, jitter(5) msymbol(none) mlabel(requestID) name(lev_cp_part) title("a) Partial, CP")
sort leverage_cp_part
linepatternst leverage_cp_part requestID proposal if leverage_cp_part>=.4 & leverage_cp_part!=. 
* Five observations stand out (120, 121, 124, 172, 173)
logistic cou_full_success sumvotes i.type amending directive recitals_initial if commonposition==1, coef
estimates store cp_full
predict leverage_cp_full, dbeta
label var leverage_cp_full "Leverage"
graph twoway scatter leverage_cp_full requestID, jitter(5) msymbol(none) mlabel(requestID) name(lev_cp_full) title("b) Full, CP")
sort leverage_cp_full
linepatternst leverage_cp_full requestID proposal if leverage_cp_full>=.4 & leverage_cp_full!=. 
* Two observations stand out (172, 173)
logistic cou_part_success sumvotes i.type amending directive recitals_initial, coef
estimates store first_part
predict leverage_first_part, dbeta
label var leverage_first_part "Leverage"
graph twoway scatter leverage_first_part requestID, jitter(5) msymbol(none) mlabel(requestID) name(lev_first_part) title("c) Partial, 1st rdg.")
sort leverage_first_part
linepatternst leverage_first_part requestID proposal if leverage_first_part>=.4 & leverage_first_part!=. 
* Five observations stand out (172, 173, 193, 194, 195)
logistic cou_full_success sumvotes i.type amending directive recitals_initial, coef
estimates store first_full
predict leverage_first_full, dbeta
label var leverage_first_full "Leverage"
graph twoway scatter leverage_first_full requestID, jitter(5) msymbol(none) mlabel(requestID) name(lev_first_full) title("d) Full, 1st rdg.")
sort leverage_first_full
linepatternst leverage_first_full requestID proposal if leverage_first_full>=.4 & leverage_first_full!=. 
* Two observations stand out (172, 173)
logistic final_part_success sumvotes i.type amending directive recitals_initial, coef
estimates store final_part
predict leverage_final_part, dbeta
label var leverage_final_part "Leverage"
graph twoway scatter leverage_final_part requestID, jitter(5) msymbol(none) mlabel(requestID) name(lev_final_part) title("c) Final, 1st rdg.")
sort leverage_final_part
linepatternst leverage_final_part requestID proposal if leverage_final_part>=.4 & leverage_final_part!=. 
* 11 observations stand out (67, 68, 69, 70, 71, 72, 172, 173, 193, 194, 195)
logistic final_full_success sumvotes i.type amending directive recitals_initial, coef
estimates store final_full
predict leverage_final_full, dbeta
label var leverage_final_full "Leverage"
graph twoway scatter leverage_final_full requestID, jitter(5) msymbol(none) mlabel(requestID) name(lev_final_full) title("d) Full, 1st rdg.")
sort leverage_final_full
linepatternst leverage_final_full requestID proposal if leverage_final_full>=.4 & leverage_final_full!=. 
* Three observations stand out (172, 173, 190)
graph combine lev_cp_part lev_cp_full lev_first_part lev_first_full lev_final_part lev_final_full, title("Figure 14: Leverage")

* Looking for commonalinepatternties for high residual (several DVs) observations
gen highres=0
replace highres=1 if requestID==58 | requestID==124 | requestID==130 | requestID==193
linepatternst proposal directive date_polagree recitals_initial type if highres==1 
 
** Comparing results for potentially problematic cases
* High residuals
logistic cou_part_success sumvotes i.type amending directive recitals_initial if commonposition==1 & highres==0, coef
estimates store cp_part_wohighres
logistic cou_full_success sumvotes i.type amending directive recitals_initial if commonposition==1  & highres==0, coef
estimates store cp_full_wohighres
logistic cou_part_success sumvotes i.type amending directive recitals_initial if highres==0, coef
estimates store first_part_wohighres
logistic cou_full_success sumvotes i.type amending directive recitals_initial if highres==0, coef
estimates store first_full_wohighres
logistic final_part_success sumvotes i.type amending directive recitals_initial if highres==0, coef
estimates store final_part_wohighres
logistic final_full_success sumvotes i.type amending directive recitals_initial if highres==0, coef
estimates store final_full_wohighres
 
estout cp_part cp_part_wohighres cp_full cp_full_wohighres first_part first_part_wohighres, stats(N r2_p p) drop(1.type) starlevels( * 0.10 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) legend mlabels(none)
estout first_full first_full_wohighres final_part final_part_wohighres final_full final_full_wohighres, stats(N r2_p p) drop(1.type) starlevels( * 0.10 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) legend mlabels(none)

* Only final success has observations with both high residuals and high leverage
* Final, part
gen highlev_final_part=0
replace highlev_final_part=1 if requestID==193 | requestID==194 | requestID==195
logistic final_part_success sumvotes i.type amending directive recitals_initial, coef
estimates store final_part
logistic final_part_success sumvotes i.type amending directive recitals_initial if highlev_final_part==0, coef
estimates store final_part_wo
* Final, full
gen highlev_final_full=0
replace highlev_final_full=1 if requestID==172 | requestID==173 
logistic final_full_success sumvotes i.type amending directive recitals_initial, coef
estimates store final_full
logistic final_full_success sumvotes i.type amending directive recitals_initial if highlev_final_full==0, coef
estimates store final_full_wo

estout final_part final_part_wo final_full final_full_wo, stats(N r2_p p) drop(1.type) starlevels( * 0.10 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) legend mlabels(none)

** Clustered/Multi-level structure
* Clustered standard errors
logistic cou_part_success sumvotes i.type amending directive recitals_initial if commonposition==1, coef cluster(proposal)
estimates store cp_part_cl
logistic cou_full_success sumvotes i.type amending directive recitals_initial if commonposition==1, coef cluster(proposal)
estimates store cp_full_cl
logistic cou_part_success sumvotes i.type amending directive recitals_initial, coef cluster(proposal)
estimates store first_part_cl
logistic cou_full_success sumvotes i.type amending directive recitals_initial, coef cluster(proposal)
estimates store first_full_cl
logistic final_part_success sumvotes i.type amending directive recitals_initial, coef cluster(proposal)
estimates store final_part_cl
logistic final_full_success sumvotes i.type amending directive recitals_initial, coef cluster(proposal)
estimates store final_full_cl

estout cp_part cp_part_cl cp_full cp_full_cl first_part first_part_cl, stats(N r2_p p) drop(1.type) starlevels( * 0.10 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) legend mlabels(none)
estout first_full first_full_cl final_part final_part_cl final_full final_full_cl, stats(N r2_p p) drop(1.type) starlevels( * 0.10 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) legend mlabels(none)

* Clustered standard errors: blocking minority
logistic cou_part_success blocking i.type amending directive recitals_initial if commonposition==1, coef cluster(proposal)
logistic cou_full_success blocking i.type amending directive recitals_initial if commonposition==1, coef cluster(proposal)
logistic cou_part_success blocking i.type amending directive recitals_initial, coef cluster(proposal)
logistic cou_full_success blocking i.type amending directive recitals_initial, coef cluster(proposal)
logistic final_part_success blocking i.type amending directive recitals_initial, coef cluster(proposal)
logistic final_full_success blocking i.type amending directive recitals_initial, coef cluster(proposal)


** Testing multilevel structure
* ICC
xtmelogit cou_part_success sumvotes i.type amending directive recitals_initial if commonposition==1 || proposal: 
estimates store cp_part_ml
estat icc
xtmelogit cou_full_success sumvotes i.type amending directive recitals_initial if commonposition==1 || proposal: 
estimates store cp_full_ml
estat icc
xtmelogit cou_part_success sumvotes i.type amending directive recitals_initial || proposal: 
estimates store first_part_ml
estat icc
xtmelogit cou_full_success sumvotes i.type amending directive recitals_initial || proposal: 
estimates store first_full_ml
estat icc
xtmelogit final_part_success sumvotes i.type amending directive recitals_initial || proposal: 
estimates store final_part_ml
estat icc
xtmelogit final_full_success sumvotes i.type amending directive recitals_initial || proposal: 
estimates store final_full_ml
estat icc
* ICC's suggest some variation due to multilevel structure
estout cp_part_ml cp_full_ml first_part_ml first_full_ml final_part_ml final_full_ml, stats(N r2_p p_c) drop(1.type) starlevels( * 0.10 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) legend mlabels(none)

* Full multilevel model with random intercept (blocking minority)
xtmelogit cou_part_success blocking i.type amending directive recitals_initial if commonposition==1 || proposal: 
estimates store cp_part_ml_h1
estat icc
xtmelogit cou_full_success blocking i.type amending directive recitals_initial if commonposition==1 || proposal: 
estimates store cp_full_ml_h1
estat icc
xtmelogit cou_part_success blocking i.type amending directive recitals_initial || proposal: 
estimates store first_part_ml_h1
estat icc
xtmelogit cou_full_success blocking i.type amending directive recitals_initial || proposal: 
estimates store first_full_ml_h1
estat icc
xtmelogit final_part_success blocking i.type amending directive recitals_initial || proposal: 
estimates store final_part_ml_h1
estat icc
xtmelogit final_full_success blocking i.type amending directive recitals_initial || proposal: 
estimates store final_full_ml_h1
estat icc
* ICC's suggest some variation due to multilevel structure
estout cp_part_ml_h1 cp_full_ml_h1 first_part_ml_h1 first_full_ml_h1 final_part_ml_h1 final_full_ml_h1, stats(N r2_p p_c) drop(1.type) starlevels( * 0.10 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) legend mlabels(none)




* Adding random effect for intercepts seems useful
** Testing for random slopes
xtmelogit cou_part_success sumvotes i.type amending directive recitals_initial if commonposition==1 || proposal: amending 
estimates store cp_part_ml_amending 
lrtest cp_part_ml_amending cp_part_ml
xtmelogit cou_full_success sumvotes i.type amending directive recitals_initial if commonposition==1 || proposal: amending 
estimates store cp_full_ml_amending
lrtest cp_full_ml_amending cp_full_ml
xtmelogit cou_part_success sumvotes i.type amending directive recitals_initial || proposal: amending 
estimates store first_part_ml_amending
lrtest first_part_ml_amending first_part_ml
xtmelogit cou_full_success sumvotes i.type amending directive recitals_initial || proposal: amending 
estimates store first_full_ml_amending
lrtest first_full_ml_amending first_full_ml
xtmelogit final_part_success sumvotes i.type amending directive recitals_initial || proposal: amending 
estimates store final_part_ml_amending
lrtest final_part_ml_amending final_part_ml
xtmelogit final_full_success sumvotes i.type amending directive recitals_initial || proposal: amending 
estimates store final_full_ml_amending
lrtest final_full_ml_amending final_full_ml
* Adding random slopes for amending does not improve model fit
xtmelogit cou_part_success sumvotes i.type amending directive recitals_initial if commonposition==1 || proposal: directive
estimates store cp_part_ml_directive 
lrtest cp_part_ml_directive cp_part_ml
xtmelogit cou_full_success sumvotes i.type amending directive recitals_initial if commonposition==1 || proposal: directive
estimates store cp_full_ml_directive
lrtest cp_full_ml_directive cp_full_ml
xtmelogit cou_part_success sumvotes i.type amending directive recitals_initial || proposal: directive 
estimates store first_part_ml_directive
lrtest first_part_ml_directive first_part_ml
xtmelogit cou_full_success sumvotes i.type amending directive recitals_initial || proposal: directive 
estimates store first_full_ml_directive
lrtest first_full_ml_directive first_full_ml
xtmelogit final_part_success sumvotes i.type amending directive recitals_initial || proposal: directive 
estimates store final_part_ml_directive
lrtest final_part_ml_directive final_part_ml
xtmelogit final_full_success sumvotes i.type amending directive recitals_initial || proposal: directive 
estimates store final_full_ml_directive
lrtest final_full_ml_directive final_full_ml
* Adding random slopes for directive does not improve model fit
xtmelogit cou_part_success sumvotes i.type amending directive recitals_initial if commonposition==1 || proposal: recitals_initial
estimates store cp_part_ml_rec 
lrtest cp_part_ml_rec cp_part_ml
xtmelogit cou_full_success sumvotes i.type amending directive recitals_initial if commonposition==1 || proposal: recitals_initial
estimates store cp_full_ml_rec
lrtest cp_full_ml_rec cp_full_ml
xtmelogit cou_part_success sumvotes i.type amending directive recitals_initial || proposal: recitals_initial
estimates store first_part_ml_rec
lrtest first_part_ml_rec first_part_ml
xtmelogit cou_full_success sumvotes i.type amending directive recitals_initial || proposal: recitals_initial
estimates store first_full_ml_rec
lrtest first_full_ml_rec first_full_ml
xtmelogit final_part_success sumvotes i.type amending directive recitals_initial || proposal: recitals_initial 
estimates store final_part_ml_rec
lrtest final_part_ml_rec final_part_ml
xtmelogit final_full_success sumvotes i.type amending directive recitals_initial || proposal: recitals_initial
estimates store final_full_ml_rec
lrtest final_full_ml_rec final_full_ml
* Adding random slopes for recitals does not improve model fit (LR test)

*** Predicted probabilinepatternties (multilevel, fixed effects only) (different types of proposals)
xtmelogit cou_part_success sumvotes i.type amending directive recitals_initial if commonposition==1 || proposal: 
margins i.type, at(sumvotes=(3(3)252) directive=1 amending=0 recitals_initial(mean)) predict(mu fixedonly)
marginsplot, noci ylabel(0(.1)1) xlabel(0(25)250, labsize(vsmall)) xtitle(, size(small)) xlinepatternne(91) ytitle("Probabilinepatternty of success") legend(off symxsize(*.7) size(vsmall) rows(1) nobox width(100)) plot1opts(msymbol(i) lpattern(solinepatternd) lwidth(medthick)) plot2opts(msymbol(i) lpattern(dash) lwidth(medthick)) plot3opts(msymbol(i) lpattern(dot) lwidth(medthick)) title("a) partial, Common Position")  name(ml_cp_part)

xtmelogit cou_full_success sumvotes i.type i.amending i.directive recitals_initial if commonposition==1 || proposal: 
margins i.type, at(sumvotes=(3(3)252) directive=1 amending=0 recitals_initial(mean)) predict(mu fixedonly)
marginsplot, noci ylabel(0(.1)1) xlabel(0(25)250, labsize(vsmall)) xtitle(, size(small)) xlinepatternne(91) ytitle("Probabilinepatternty of success") legend(off) plot1opts(msymbol(i) lpattern(solinepatternd) lwidth(medthick)) plot2opts(msymbol(i) lpattern(dash) lwidth(medthick)) plot3opts(msymbol(i) lpattern(dot) lwidth(medthick)) title("b) full, Common Position") name(ml_cp_full)

xtmelogit cou_part_success sumvotes i.type i.amending i.directive recitals_initial || proposal: 
margins i.type, at(sumvotes=(3(3)252) directive=1 amending=0 recitals_initial(mean)) predict(mu fixedonly)
marginsplot, noci ylabel(0(.1)1) xlabel(0(25)250, labsize(vsmall)) xtitle(, size(small)) xlinepatternne(91) ytitle("Probabilinepatternty of success") legend(off) plot1opts(msymbol(i) lpattern(solinepatternd) lwidth(medthick)) plot2opts(msymbol(i) lpattern(dash) lwidth(medthick)) plot3opts(msymbol(i) lpattern(dot) lwidth(medthick)) title("c) partial, first reading") name(ml_first_part)

xtmelogit cou_full_success sumvotes i.type i.amending i.directive recitals_initial || proposal: 
margins i.type, at(sumvotes=(3(3)252) directive=1 amending=0 recitals_initial(mean)) predict(mu fixedonly)
marginsplot, noci ylabel(0(.1)1) xlabel(0(25)250, labsize(vsmall)) xtitle(, size(small)) xlinepatternne(91) ytitle("Probabilinepatternty of success") legend(off) plot1opts(msymbol(i) lpattern(solinepatternd) lwidth(medthick)) plot2opts(msymbol(i) lpattern(dash) lwidth(medthick)) plot3opts(msymbol(i) lpattern(dot) lwidth(medthick)) title("d) full, first reading") name(ml_first_full)

xtmelogit final_part_success sumvotes i.type i.amending i.directive recitals_initial || proposal: 
margins i.type, at(sumvotes=(3(3)252) directive=1 amending=0 recitals_initial(mean)) predict(mu fixedonly)
marginsplot, noci ylabel(0(.1)1) xlabel(0(25)250, labsize(vsmall)) xtitle(, size(small)) xlinepatternne(91) ytitle("Probabilinepatternty of success") legend(off) plot1opts(msymbol(i) lpattern(solinepatternd) lwidth(medthick)) plot2opts(msymbol(i) lpattern(dash) lwidth(medthick)) plot3opts(msymbol(i) lpattern(dot) lwidth(medthick)) title("e) partial, final outcome") name(ml_final_part)

xtmelogit final_full_success sumvotes i.type i.amending i.directive recitals_initial || proposal: 
margins i.type, at(sumvotes=(3(3)252) directive=1 amending=0 recitals_initial(mean)) predict(mu fixedonly)
marginsplot, noci ylabel(0(.1)1) xlabel(0(25)250, labsize(vsmall)) xtitle(, size(small)) xlinepatternne(91) ytitle("Probabilinepatternty of success") legend(off) plot1opts(msymbol(i) lpattern(solinepatternd) lwidth(medthick)) plot2opts(msymbol(i) lpattern(dash) lwidth(medthick)) plot3opts(msymbol(i) lpattern(dot) lwidth(medthick)) title("f) full, final outcome") name(ml_final_full)

grc1leg ml_cp_part ml_cp_full ml_first_part ml_first_full ml_final_part ml_final_full, ycommon title("Figure 15: Predicted probabilinepatternties of success (multilevel model)") note("Note: Multilevel model with random intercepts, only fixed effects used for predicted probabilinepatterntes." "Predictions are for directives, not amending, with recitals set at their mean value" "Vertical linepatternne denotes threshold for blocking minority", size(vsmall))
grc1leg ml_cp_part ml_cp_full ml_first_part ml_first_full ml_final_part ml_final_full, ycommon title("Figure 4: Predicted probabilinepatternties of success (multilevel model)") note("Note: Multilevel model with random intercepts, only fixed effects used for predicted probabilinepatterntes." "Predictions are for directives, not amending, with recitals set at their mean value" "Vertical linepatternne denotes threshold for blocking minority", size(vsmall))
grc1leg ml_cp_part ml_cp_full ml_first_part ml_first_full ml_final_part ml_final_full, ycommon 

*** Predicted probabilinepatternties with CI
xtmelogit cou_part_success sumvotes derogation extension amending directive recitals_initial if commonposition==1 || proposal: 
margins, at(sumvotes=(3(3)252) directive=1 derogation=1 extension=0 amending=0 recitals_initial(mean)) predict(mu fixedonly)
marginsplot, recastci(rarea) ylabel(0(.1)1) xlabel(0(25)250, labsize(vsmall)) xtitle(, size(small)) xlinepatternne(91) ytitle("Probabilinepatternty of success") legend(off) plot1opts(msymbol(i) lpattern(solinepatternd) lwidth(medthick)) title("a) Derogations")  name(ml_cp_part_der)
margins, at(sumvotes=(3(3)252) directive=1 derogation=0 extension=1 amending=0 recitals_initial(mean)) predict(mu fixedonly)
marginsplot, recastci(rarea) ylabel(0(.1)1) xlabel(0(25)250, labsize(vsmall)) xtitle(, size(small)) xlinepatternne(91) ytitle("Probabilinepatternty of success") legend(off) plot1opts(msymbol(i) lpattern(solinepatternd) lwidth(medthick)) title("b) Extensions")  name(ml_cp_part_ext)
margins, at(sumvotes=(3(3)252) directive=1 derogation=0 extension=0 amending=0 recitals_initial(mean)) predict(mu fixedonly)
marginsplot, recastci(rarea) ylabel(0(.1)1) xlabel(0(25)250, labsize(vsmall)) xtitle(, size(small)) xlinepatternne(91) ytitle("Probabilinepatternty of success") legend(off) plot1opts(msymbol(i) lpattern(solinepatternd) lwidth(medthick)) title("c) Lower standards")  name(ml_cp_part_low)
graph combine ml_cp_part_der ml_cp_part_ext ml_cp_part_low, ycommon title("Figure 16: Predicted probabilinepatternties of success (partial, Common Position)", size(medium)) note("Note: Multilevel model with random intercepts, only fixed effects used for predicted probabilinepatterntes." "Predictions are for directives, not amending, with recitals set at their mean value" "Vertical linepatternne denotes threshold for blocking minority", size(vsmall))

xtmelogit cou_full_success sumvotes derogation extension amending directive recitals_initial if commonposition==1 || proposal: 
margins, at(sumvotes=(3(3)252) directive=1 derogation=1 extension=0 amending=0 recitals_initial(mean)) predict(mu fixedonly)
marginsplot, recastci(rarea) ylabel(0(.1)1) xlabel(0(25)250, labsize(vsmall)) xtitle(, size(small)) xlinepatternne(91) ytitle("Probabilinepatternty of success") legend(off) plot1opts(msymbol(i) lpattern(solinepatternd) lwidth(medthick)) title("a) Derogations")  name(ml_cp_full_der)
margins, at(sumvotes=(3(3)252) directive=1 derogation=0 extension=1 amending=0 recitals_initial(mean)) predict(mu fixedonly)
marginsplot, recastci(rarea) ylabel(0(.1)1) xlabel(0(25)250, labsize(vsmall)) xtitle(, size(small)) xlinepatternne(91) ytitle("Probabilinepatternty of success") legend(off) plot1opts(msymbol(i) lpattern(solinepatternd) lwidth(medthick)) title("b) Extensions")  name(ml_cp_full_ext)
margins, at(sumvotes=(3(3)252) directive=1 derogation=0 extension=0 amending=0 recitals_initial(mean)) predict(mu fixedonly)
marginsplot, recastci(rarea) ylabel(0(.1)1) xlabel(0(25)250, labsize(vsmall)) xtitle(, size(small)) xlinepatternne(91) ytitle("Probabilinepatternty of success") legend(off) plot1opts(msymbol(i) lpattern(solinepatternd) lwidth(medthick)) title("c) Lower standards")  name(ml_cp_full_low)
graph combine ml_cp_full_der ml_cp_full_ext ml_cp_full_low, ycommon title("Figure 17: Predicted probabilinepatternties of success (full, Common Position)", size(medium)) note("Note: Multilevel model with random intercepts, only fixed effects used for predicted probabilinepatterntes." "Predictions are for directives, not amending, with recitals set at their mean value" "Vertical linepatternne denotes threshold for blocking minority", size(vsmall))

xtmelogit cou_part_success sumvotes derogation extension amending directive recitals_initial || proposal: 
margins, at(sumvotes=(3(3)252) directive=1 derogation=1 extension=0 amending=0 recitals_initial(mean)) predict(mu fixedonly)
marginsplot, recastci(rarea) ylabel(0(.1)1) xlabel(0(25)250, labsize(vsmall)) xtitle(, size(small)) xlinepatternne(91) ytitle("Probabilinepatternty of success") legend(off) plot1opts(msymbol(i) lpattern(solinepatternd) lwidth(medthick)) title("a) Derogations")  name(ml_fr_part_der)
margins, at(sumvotes=(3(3)252) directive=1 derogation=0 extension=1 amending=0 recitals_initial(mean)) predict(mu fixedonly)
marginsplot, recastci(rarea) ylabel(0(.1)1) xlabel(0(25)250, labsize(vsmall)) xtitle(, size(small)) xlinepatternne(91) ytitle("Probabilinepatternty of success") legend(off) plot1opts(msymbol(i) lpattern(solinepatternd) lwidth(medthick)) title("b) Extensions")  name(ml_fr_part_ext)
margins, at(sumvotes=(3(3)252) directive=1 derogation=0 extension=0 amending=0 recitals_initial(mean)) predict(mu fixedonly)
marginsplot, recastci(rarea) ylabel(0(.1)1) xlabel(0(25)250, labsize(vsmall)) xtitle(, size(small)) xlinepatternne(91) ytitle("Probabilinepatternty of success") legend(off) plot1opts(msymbol(i) lpattern(solinepatternd) lwidth(medthick)) title("c) Lower standards")  name(ml_fr_part_low)
graph combine ml_fr_part_der ml_fr_part_ext ml_fr_part_low, ycommon title("Figure 18: Predicted probabilinepatternties of success (partial, 1st reading)", size(medium)) note("Note: Multilevel model with random intercepts, only fixed effects used for predicted probabilinepatterntes." "Predictions are for directives, not amending, with recitals set at their mean value" "Vertical linepatternne denotes threshold for blocking minority", size(vsmall))

xtmelogit cou_full_success sumvotes derogation extension amending directive recitals_initial || proposal: 
margins, at(sumvotes=(3(3)252) directive=1 derogation=1 extension=0 amending=0 recitals_initial(mean)) predict(mu fixedonly)
marginsplot, recastci(rarea) ylabel(0(.1)1) xlabel(0(25)250, labsize(vsmall)) xtitle(, size(small)) xlinepatternne(91) ytitle("Probabilinepatternty of success") legend(off) plot1opts(msymbol(i) lpattern(solinepatternd) lwidth(medthick)) title("a) Derogations")  name(ml_fr_full_der)
margins, at(sumvotes=(3(3)252) directive=1 derogation=0 extension=1 amending=0 recitals_initial(mean)) predict(mu fixedonly)
marginsplot, recastci(rarea) ylabel(0(.1)1) xlabel(0(25)250, labsize(vsmall)) xtitle(, size(small)) xlinepatternne(91) ytitle("Probabilinepatternty of success") legend(off) plot1opts(msymbol(i) lpattern(solinepatternd) lwidth(medthick)) title("b) Extensions")  name(ml_fr_full_ext)
margins, at(sumvotes=(3(3)252) directive=1 derogation=0 extension=0 amending=0 recitals_initial(mean)) predict(mu fixedonly)
marginsplot, recastci(rarea) ylabel(0(.1)1) xlabel(0(25)250, labsize(vsmall)) xtitle(, size(small)) xlinepatternne(91) ytitle("Probabilinepatternty of success") legend(off) plot1opts(msymbol(i) lpattern(solinepatternd) lwidth(medthick)) title("c) Lower standards")  name(ml_fr_full_low)
graph combine ml_fr_full_der ml_fr_full_ext ml_fr_full_low, ycommon title("Figure 19: Predicted probabilinepatternties of success (full, 1st reading)", size(medium)) note("Note: Multilevel model with random intercepts, only fixed effects used for predicted probabilinepatterntes." "Predictions are for directives, not amending, with recitals set at their mean value" "Vertical linepatternne denotes threshold for blocking minority", size(vsmall))

xtmelogit final_part_success sumvotes derogation extension amending directive recitals_initial || proposal: 
margins, at(sumvotes=(3(3)252) directive=1 derogation=1 extension=0 amending=0 recitals_initial(mean)) predict(mu fixedonly)
marginsplot, recastci(rarea) ylabel(0(.1)1) xlabel(0(25)250, labsize(vsmall)) xtitle(, size(small)) xlinepatternne(91) ytitle("Probabilinepatternty of success") legend(off) plot1opts(msymbol(i) lpattern(solinepatternd) lwidth(medthick)) title("a) Derogations")  name(ml_final_part_der)
margins, at(sumvotes=(3(3)252) directive=1 derogation=0 extension=1 amending=0 recitals_initial(mean)) predict(mu fixedonly)
marginsplot, recastci(rarea) ylabel(0(.1)1) xlabel(0(25)250, labsize(vsmall)) xtitle(, size(small)) xlinepatternne(91) ytitle("Probabilinepatternty of success") legend(off) plot1opts(msymbol(i) lpattern(solinepatternd) lwidth(medthick)) title("b) Extensions")  name(ml_final_part_ext)
margins, at(sumvotes=(3(3)252) directive=1 derogation=0 extension=0 amending=0 recitals_initial(mean)) predict(mu fixedonly)
marginsplot, recastci(rarea) ylabel(0(.1)1) xlabel(0(25)250, labsize(vsmall)) xtitle(, size(small)) xlinepatternne(91) ytitle("Probabilinepatternty of success") legend(off) plot1opts(msymbol(i) lpattern(solinepatternd) lwidth(medthick)) title("c) Lower standards")  name(ml_final_part_low)
graph combine ml_final_part_der ml_final_part_ext ml_final_part_low, ycommon title("Figure 20: Predicted probabilinepatternties of success (partial, final)", size(medium)) note("Note: Multilevel model with random intercepts, only fixed effects used for predicted probabilinepatterntes." "Predictions are for directives, not amending, with recitals set at their mean value" "Vertical linepatternne denotes threshold for blocking minority", size(vsmall))

xtmelogit final_full_success sumvotes derogation extension amending directive recitals_initial || proposal: 
margins, at(sumvotes=(3(3)252) directive=1 derogation=1 extension=0 amending=0 recitals_initial(mean)) predict(mu fixedonly)
marginsplot, recastci(rarea) ylabel(0(.1)1) xlabel(0(25)250, labsize(vsmall)) xtitle(, size(small)) xlinepatternne(91) ytitle("Probabilinepatternty of success") legend(off) plot1opts(msymbol(i) lpattern(solinepatternd) lwidth(medthick)) title("a) Derogations")  name(ml_final_full_der)
margins, at(sumvotes=(3(3)252) directive=1 derogation=0 extension=1 amending=0 recitals_initial(mean)) predict(mu fixedonly)
marginsplot, recastci(rarea) ylabel(0(.1)1) xlabel(0(25)250, labsize(vsmall)) xtitle(, size(small)) xlinepatternne(91) ytitle("Probabilinepatternty of success") legend(off) plot1opts(msymbol(i) lpattern(solinepatternd) lwidth(medthick)) title("b) Extensions")  name(ml_final_full_ext)
margins, at(sumvotes=(3(3)252) directive=1 derogation=0 extension=0 amending=0 recitals_initial(mean)) predict(mu fixedonly)
marginsplot, recastci(rarea) ylabel(0(.1)1) xlabel(0(25)250, labsize(vsmall)) xtitle(, size(small)) xlinepatternne(91) ytitle("Probabilinepatternty of success") legend(off) plot1opts(msymbol(i) lpattern(solinepatternd) lwidth(medthick)) title("c) Lower standards")  name(ml_final_full_low)
graph combine ml_final_full_der ml_final_full_ext ml_final_full_low, ycommon title("Figure 21: Predicted probabilinepatternties of success (full, final)", size(medium)) note("Note: Multilevel model with random intercepts, only fixed effects used for predicted probabilinepatterntes." "Predictions are for directives, not amending, with recitals set at their mean value" "Vertical linepatternne denotes threshold for blocking minority", size(vsmall))

*** Predicted probabilinepatternties (multilevel, fixed effects only) (combined graph, across stages and degree of success)
xtmelogit cou_part_success sumvotes derogation extension amending directive recitals_initial if commonposition==1 || proposal: 
margins, at(sumvotes=(3(3)252) directive=1 derogation=1 extension=0 amending=0 recitals_initial(mean)) predict(mu fixedonly) saving(margins_cp_part, replace)
xtmelogit cou_full_success sumvotes derogation extension amending directive recitals_initial if commonposition==1 || proposal: 
margins, noci at(sumvotes=(3(3)252) directive=1 derogation=1 extension=0 amending=0 recitals_initial(mean)) predict(mu fixedonly) saving(margins_cp_full, replace)
xtmelogit cou_part_success sumvotes derogation extension amending directive recitals_initial || proposal: 
margins, noci at(sumvotes=(3(3)252) directive=1 derogation=1 extension=0 amending=0 recitals_initial(mean)) predict(mu fixedonly) saving(margins_first_part, replace)
xtmelogit cou_full_success sumvotes derogation extension amending directive recitals_initial || proposal: 
margins, at(sumvotes=(3(3)252) directive=1 derogation=1 extension=0 amending=0 recitals_initial(mean)) predict(mu fixedonly) saving(margins_first_full, replace)
xtmelogit final_part_success sumvotes derogation extension amending directive recitals_initial || proposal: 
margins, at(sumvotes=(3(3)252) directive=1 derogation=1 extension=0 amending=0 recitals_initial(mean)) predict(mu fixedonly) saving(margins_final_part, replace)
xtmelogit final_full_success sumvotes derogation extension amending directive recitals_initial || proposal: 
margins, at(sumvotes=(3(3)252) directive=1 derogation=1 extension=0 amending=0 recitals_initial(mean)) predict(mu fixedonly) saving(margins_final_full, replace)
combomarginsplot margins_cp_part margins_cp_full margins_first_part margins_first_full margins_final_part margins_final_full, noci labels("Common Position, partial" "Common Position, full" "First reading, partial" "First reading, full" "Final, partial" "Final, full")  file1opts(pstyle(p1)) file2opts(pstyle(p7)) file3opts(pstyle(p2)) file4opts(pstyle(p8)) file5opts(pstyle(p3)) file6opts(pstyle(p9))

